home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / src / portable / outopts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  9.8 KB  |  297 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. #define    CURSES_LIBRARY    1
  20. #include <curses.h>
  21.  
  22. /* undefine any macros for functions defined in this module */
  23. #undef    clearok
  24. #undef    idlok
  25. #undef    idcok
  26. #undef    immedok
  27. #undef    leaveok
  28. #undef    setscrreg
  29. #undef    wsetscrreg
  30. #undef    scrollok
  31. #undef    nl
  32. #undef    nonl
  33. #undef    raw_output
  34.  
  35. /* undefine any macros for functions called by this module if in debug mode */
  36. #ifdef PDCDEBUG
  37. #endif
  38.  
  39. #ifdef PDCDEBUG
  40. char *rcsid_outopts  = "$Id$";
  41. #endif
  42.  
  43. /*man-start*********************************************************************
  44.  
  45.   Name:                                                       outopts
  46.  
  47.   Synopsis:
  48.       int clearok(WINDOW *win, bool bf);
  49.       int idlok( WINDOW *win, bool bf );
  50.       int idcok( WINDOW *win, bool bf );
  51.   ***    int immedok( WINDOW *win, bool bf );
  52.       int leaveok( WINDOW *win, bool bf );
  53.       int setscrreg(int top, int bot);
  54.       int wsetscrreg(WINDOW *win, int top, int bot);
  55.       int scrollok(WINDOW *win, bool bf);
  56.       int nl(void);
  57.       int nonl(void);
  58.  
  59.       int raw_output(bool bf);
  60.  
  61.   X/Open Description:
  62.      With the clearok() routine, if bf is TRUE, the next call to 
  63.      wrefresh() with this window will clear the screen completely 
  64.      and redraw the entire screen.
  65.  
  66.      If idlok() is enabled (bf is TRUE), curses will use the insert/delete
  67.      line feature of terminals so equipped.  If disabled, curses will not
  68.      use this feature.  (The insert/delete character feature is always
  69.      used.)  This option should be enabled only if the application
  70.      needs insert/delete line; for example, for a screen editor.  It
  71.      is disabled by default because insert/delete line tends to be
  72.      visually annoying when used in applications where it isn't really
  73.      needed.  If insert/delete line cannot be used, curses will redraw
  74.      the changed portions of all lines.
  75.  
  76.      With the idcok() routine, if enabled (bf is TRUE), curses considers
  77.      using the hardware insert/delete character feature of terminals so 
  78.      equipped. This is enabled by default.
  79.  
  80.      Normally, the hardware cursor is left at the location of the
  81.      window being refreshed.  leaveok() allows the cursor to be
  82.      left whereever the update happens to leave it.  It is useful
  83.      for applications where the cursor is not used, since it reduces
  84.      the need for cursor motions.  If possible, the cursor is made
  85.      invisible when this option is enabled.
  86.  
  87.      The setscrreg() and wsetscrreg() functions allow the user to set 
  88.      a software scrolling region in a window.  The parameters 'top' 
  89.      and 'bot' are the line numbers of the top and bottom margin of the 
  90.      scrolling region.  (Line 0 is the top line of the window.)  If this 
  91.      option and scrollok() are enabled, an attempt to move off the bottom 
  92.      margin will cause all lines in the scrolling region to scroll up one 
  93.      line.  Only the text of the window is scrolled.
  94.  
  95.      The nl() function enables the translation of newline into a
  96.      carriage return and a line-feed on output, and a carriage return
  97.      is translated into a newline on input.  Initially, the translations
  98.      do occur.  By disabling these translations, curses is able to
  99.      make better use of the line-feed capability, resulting in faster
  100.      cursor motion.
  101.  
  102.      The nonl() function disables the translation of newline into a
  103.      carriage return and a line-feed on output, and a carriage return
  104.      is translated into a newline on input.  Initially, the translations
  105.      do occur.  By disabling these translations, curses is able to
  106.      make better use of the line-feed capability, resulting in faster
  107.      cursor motion.
  108.  
  109.   PDCurses Description:
  110.      idlok() and idcok() are provided for portability.  
  111.      This may have some value for the FLEXOS platform, but there is 
  112.      no code in PDCurses at this time (910725) that takes advantage 
  113.      of this.
  114.  
  115.      Though not explicitly stated, the cursor will be made visible
  116.      again, if leaveok() is passed a FALSE value.
  117.              (Frotz:911226 Comments?)
  118.  
  119.      The raw_output() routine enables the output of raw characters using 
  120.      the 'standard' *add* and *ins* curses functions.
  121.      To force 8 bit output and no translation of control characters,
  122.      invoke raw_output() with bf as TRUE.  To force 7 bit output and
  123.      translation of control characters, invoke raw_output() with bf
  124.      as FALSE.
  125.  
  126.   X/Open Return Value:
  127.      All functions return OK on success and ERR on error.
  128.  
  129.   X/Open Errors:
  130.      No errors are defined for this function.
  131.  
  132.   Portability                             X/Open    BSD    SYS V
  133.                                           Dec '88
  134.       clearok                               Y        Y       Y
  135.       idlok                                 Y        Y       Y
  136.       idcok                                 -        -      4.0
  137.       immedok                               -        -      4.0
  138.       leaveok                               Y        Y       Y
  139.       setscrreg                             Y        Y       Y
  140.       wsetscrreg                            Y        Y       Y
  141.       scrollok                              Y        Y       Y
  142.       nl                                    Y        Y       Y
  143.       nonl                                  Y        Y       Y
  144.       raw_output                            -        -       -
  145.  
  146. **man-end**********************************************************************/
  147.  
  148. /***********************************************************************/
  149. int    clearok(WINDOW *win, bool bf)
  150. /***********************************************************************/
  151. {
  152. #ifdef PDCDEBUG
  153.     if (trace_on) PDC_debug("clearok() - called\n");
  154. #endif
  155.  
  156.     if (win == (WINDOW *)NULL)
  157.         return( ERR );
  158.  
  159.     win->_clear = bf;
  160.     if( bf )
  161.         touchwin( win );
  162.  
  163.     return( OK );
  164. }
  165. /***********************************************************************/
  166. int    idlok( WINDOW *win, bool bf )
  167. /***********************************************************************/
  168. {
  169. #ifdef PDCDEBUG
  170.     if (trace_on) PDC_debug("idlok() - called\n");
  171. #endif
  172.  
  173.     win->_use_idl = bf;
  174.     return( OK );
  175. }
  176. /***********************************************************************/
  177. int    idcok( WINDOW *win, bool bf )
  178. /***********************************************************************/
  179. {
  180. #ifdef PDCDEBUG
  181.     if (trace_on) PDC_debug("idcok() - called\n");
  182. #endif
  183.  
  184.     win->_use_idc = bf;
  185.     return( OK );
  186. }
  187. /***********************************************************************/
  188. int    leaveok( WINDOW *win, bool bf )
  189. /***********************************************************************/
  190. {
  191. #ifdef PDCDEBUG
  192.     if (trace_on) PDC_debug("leaveok() - called\n");
  193. #endif
  194.  
  195.     if  ((win->_leave = bf) != 0)    PDC_cursor_off();
  196.     else                PDC_cursor_on();
  197.     return( OK );
  198. }
  199. /***********************************************************************/
  200. int    setscrreg(int top, int bottom)
  201. /***********************************************************************/
  202. {
  203. #ifdef PDCDEBUG
  204.     if (trace_on) PDC_debug("setscrreg() - called: top %d bottom %d\n",top,bottom);
  205. #endif
  206.  
  207.     if (stdscr == (WINDOW *)NULL)
  208.         return (ERR);
  209.  
  210.     if ((0 <= top) &&
  211.         (top <= stdscr->_cury) &&
  212.         (stdscr->_cury <= bottom) &&
  213.         (bottom < LINES))
  214.     {
  215.         stdscr->_tmarg = top;
  216.         stdscr->_bmarg = bottom;
  217.         return (OK);
  218.     }
  219.     else
  220.     {
  221.         return (ERR);
  222.     }
  223. }
  224. /***********************************************************************/
  225. int    wsetscrreg(WINDOW *win, int top, int bottom)
  226. /***********************************************************************/
  227. {
  228. #ifdef PDCDEBUG
  229.     if (trace_on) PDC_debug("wsetscrreg() - called: top %d bottom %d\n",top,bottom);
  230. #endif
  231.  
  232.     if (win == (WINDOW *)NULL)
  233.         return (ERR);
  234.  
  235.     if ((0 <= top) &&
  236.         (top <= win->_cury) &&
  237.         (win->_cury <= bottom) &&
  238.         (bottom < win->_maxy))
  239.     {
  240.         win->_tmarg = top;
  241.         win->_bmarg = bottom;
  242.         return (OK);
  243.     }
  244.     else
  245.     {
  246.         return (ERR);
  247.     }
  248. }
  249. /***********************************************************************/
  250. int    scrollok(WINDOW *win, bool bf)
  251. /***********************************************************************/
  252. {
  253. #ifdef PDCDEBUG
  254.     if (trace_on) PDC_debug("scrollok() - called\n");
  255. #endif
  256.  
  257.     if  (win == (WINDOW *)NULL)
  258.         return( ERR );
  259.  
  260.     win->_scroll    = bf;
  261.     return( OK );
  262. }
  263. /***********************************************************************/
  264. int    nl(void)
  265. /***********************************************************************/
  266. {
  267. #ifdef PDCDEBUG
  268.     if (trace_on) PDC_debug("nl() - called\n");
  269. #endif
  270.  
  271.     _cursvar.autocr = TRUE;
  272.     return( OK );
  273. }
  274. /***********************************************************************/
  275. int    nonl(void)
  276. /***********************************************************************/
  277. {
  278. #ifdef PDCDEBUG
  279.     if (trace_on) PDC_debug("nonl() - called\n");
  280. #endif
  281.  
  282.     _cursvar.autocr = FALSE;
  283.     return( OK );
  284. }
  285. /***********************************************************************/
  286. int    raw_output(bool bf)
  287. /***********************************************************************/
  288. {
  289. #ifdef PDCDEBUG
  290.     if (trace_on) PDC_debug("raw_output() - called\n");
  291. #endif
  292.  
  293.     _cursvar.raw_out = bf;
  294.     return( OK );
  295. }
  296.